package cn.cloudplug.friendsrecommend.view;

import cn.cloudplug.friendsrecommend.R;
import cn.cloudplug.friendsrecommend.util.Constant;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class AppTitleLayoutView extends RelativeLayout{
	private ImageView iv_home;
	private TextView tv_title;
	private ImageView iv_more;
	private Context context;
	public AppTitleLayoutView(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.context=context;
		setView();
		fillData(attrs);
	}
	
	private void fillData(AttributeSet attrs) {
		int home=attrs.getAttributeResourceValue(Constant.NAMESPACE, "src_home", 0);
		int more=attrs.getAttributeResourceValue(Constant.NAMESPACE, "src_more", 0);
		String text=attrs.getAttributeValue(Constant.NAMESPACE,"text");
		iv_home.setImageResource(home);
		tv_title.setText(text);
		if(more!=0){
			iv_more.setVisibility(View.VISIBLE);
			iv_more.setImageResource(more);
		}
		
	}

	
	private void setView() {
		View.inflate(context, R.layout.app_title_layout, this);
		iv_home=(ImageView) findViewById(R.id.iv_home);
		tv_title=(TextView) findViewById(R.id.tv_title);
		iv_more=(ImageView) findViewById(R.id.iv_more);
	}

}
